package com.rtf.framework.dao.rule.unique;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface UniqueCodeRecordDao {
    @Select("<script>" +
            "SELECT COUNT(1) " +
            "FROM ${table_name} " +
            "WHERE code = #{code} " +
            "<if test=\"excludeId != null and excludeId != ''\">" +
            "   AND ( id > #{excludeId} OR id <![CDATA[<]]> #{excludeId} )" +
            "</if>" +
            "</script>")
    int queryExistCount(@Param("table_name") String tableName,
                        @Param("code") String code,
                        @Param("excludeId") Long excludeId);
}
